<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<!--标准mui.css-->
		<link rel="stylesheet" href="../../css/mui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../../css/app.css" />
		<script src="../../js/getURLParam.js"></script>
		<style>
			.chart {
				height: 200px;
				margin: 0px;
				padding: 0px;
			}
		</style>
	</head>

	<body>

		<!--下拉刷新容器-->
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<!--数据列表-->
				<ul class="mui-table-view " id="list">
				</ul>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../libs/echarts-all.js"></script>
		<script>
			var sessionid=GetQueryString("sessionid");
			var accountid=GetQueryString("accountId");
	        var proversion=GetQueryString("proVersion");
	        var f = document.getElementById("list");
	        var cont=0;
	        var msglist="";
	        function getmsglist(){
				mui.ajax('../../../APP/msgList', {
					data: {
						param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '","data":{"type":"1"}}'
					},
					dataType: 'jsonp', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						var jsonObj = window.JSON.parse(data);
						if (jsonObj.resultCode == "1") {
							//获取返回数据的data
							var resultdata = jsonObj.data
							jsondata = jsonObj.data;
							var li=""
							if (resultdata!=null) {
								var dataList = resultdata.msgList;
								msglist=dataList;
								if(dataList.length>0){
									//if(dataList.length>10){
										for(var i=0;i<dataList.length;i++){
											li+='<li id="a_'+dataList[i].vclid+'_'+dataList[i].vclnum+'_'+dataList[i].flttime+'_'+dataList[i].fltspn+'_'+dataList[i].fltfmi+'" class="mui-table-view-cell" style="padding-right:0px"><div class="mui-navigate-right">'+dataList[i].vclnum+'&nbsp;&nbsp;'+dataList[i].fltcode+'&nbsp;&nbsp;<span>'+dataList[i].flttime+'</span><br><p style="word-break:break-all">故障描述:' + dataList[i].fltcont+ '</p></div></li>';
											cont++;
										}
								}
								f.innerHTML=li;
							} else {
								document.getElementById("dd").innerHTML=jsonObj.resultCode;
								f.innerHTML = "暂无数据"+resultdata.length;
							}
					}else{
						f.innerHTML = "错误代码"+jsonObj.resultCode;
					}
					mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						f.innerHTML = "error";
					}
				});
			}
			mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					down: {
						callback: pulldownRefresh,
						auto:true
					}
				}
			});
			var count = 0;
			/**
			 * 下拉刷新具体业务实现
			 */
			function pulldownRefresh() {
				
				//mui('#refreshContainer').pullRefresh().endPulldownToRefresh();
				setTimeout(function() {
					getmsglist();
				}, 1000);
			}
			function close123(obj){
				mui.closePopup();
			}
			//点击弹出框
			mui("#pullrefresh").on("tap","li",function(){
				var id=this.getAttribute("id");
				var vclId=id.split("_")[1];
				var vclNum=id.split("_")[2];
				var fltTime=id.split("_")[3];
				var fltFmi=id.split("_")[5];
				var fltSpn=id.split("_")[4];
				mui.ajax('../../../APP/thFltState', {
					data: {
						param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '","data":{"vclId":"'+vclId+'","vclNum":"'+vclNum+'","fltTime":"'+fltTime+'","fltFmi":"'+fltFmi+'","fltSpn":"'+fltSpn+'"}}'
					},
					dataType: 'jsonp', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					timeout: 100000, //超时时间设置为10秒；
					success: function(data) {
						var jsonObj = window.JSON.parse(data);
						if (jsonObj.resultCode == "1") {
							//获取返回数据的data
							var resultdata = jsonObj.data
							jsondata = jsonObj.data;
							var btnArray = ['<div style="background-color:#149DDD;color:white">现行故障</div>'];
							var msgString='<div style="text-align:left;color:grey"><div>故障代码：'+jsondata.fltcode+'</div><div>故障时间：'+jsondata.flttime+'</div><div style="font-weight:bold;color:black">故障状态：'+jsondata.fltstate+'</div><div>故障描述：'+jsondata.fltaddr+'</div><p>故障风险：'+jsondata.fltrisk+'</p>';
							if("已解除"==jsondata.fltstate){
								msgString+='<p>解除时间：'+jsondata.releasetime+'</p>'
							}
							msgString+='<div>';
							var titleString='<p style="height:15px"><span style="font-weight:bolder;color:#000000;font-size:16px">'+jsondata.vclnum+'</span><a style="float:right;font-size:14px" id="aa123" onclick="close123(this)" >关闭</a></p><hr>';
							//<a style="font-size:30px" id="aa123" onclick="close123(this)">×</a>
							mui.confirm(msgString,titleString , btnArray, function(e) {
									if (e.index == -1) {
										//现行故障;
										window.webkit.messageHandlers.msgListFltCurt.postMessage(vclId+"_"+vclNum);
									}
							});
							
					}else{
						f.innerHTML = "错误代码"+resultdata.resultCode;
					}},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						//f.innerHTML = "error";
					}
				});
			})
		</script>
	</body>

</html>